package com.shimao.celnet.payment.service.impl;

import com.shimao.celnet.payment.model.PInvoiceRedDetail;
import com.shimao.celnet.payment.service.PInvoiceRedDetailService;
import com.shimao.celnet.payment.util.FinalUtil;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class PInvoiceRedDetailServiceImpl extends BaseServiceImpl<PInvoiceRedDetail> implements PInvoiceRedDetailService{

    protected Logger logger = Logger.getLogger(this.getClass());

    /**
     * 根据红票guid，查询开票明细
     * @param invoiceGuid:蓝票guid
     * @return
     */
    @Override
    public List<PInvoiceRedDetail> getByInvoiceGuid(String invoiceGuid){
        Example example = new Example(PInvoiceRedDetail.class);
        Example.Criteria criteria = example.createCriteria();
        //开票guid
        criteria.andEqualTo("invoiceGuid", invoiceGuid );
        List<PInvoiceRedDetail> tableList = getByExample(example);
        return tableList;
    }

    /**
     *新增保存
     * @return
     */
    @Override
    public int save(PInvoiceRedDetail sBean){
        int retCnt=0;
        String loginUserGuid = FinalUtil.INTER_FACE_USER_ID;;
        sBean.setUpdateUserGuid(loginUserGuid);
        sBean.setCreatedUserGuid(loginUserGuid);
        sBean.setGuid(getGuid());//guid
        retCnt = super.save(sBean);

        return retCnt;
    }

    /**
     *修改保存
     * @return
     */
    @Override
    public int update(PInvoiceRedDetail sBean){
        String loginUserGuid = FinalUtil.INTER_FACE_USER_ID;;
        sBean.setUpdateUserGuid(loginUserGuid);
        int retCnt = super.update(sBean);

        return retCnt;
    }
}
